/*    */ package bdSQL;
/*    */ 
import base.Setor;
/*    */ import base.Usuario;
/*    */ import java.sql.ResultSet;
/*    */ 
/*    */ public class LoginAction
/*    */ {
/*  9 */   String sql = "";
/*    */ 
/*    */   public Usuario verificaAcesso(String login, String senha) {
/* 12 */     Banco banco = Banco.getInstance();
/* 13 */     Usuario usuario = new Usuario();
             
/* 14 */     String log = login.replace('\'', ' ');
/* 15 */     log = log.replace('"', ' ');
/* 16 */     String sen = senha.replace('\'', ' ');
/* 17 */     senha = sen.replace('"', ' ');
/* 18 */     this.sql = ("SELECT * FROM usuario WHERE login = '" + log + "' AND (pwdcompare('" + sen + "', senha, 0) = 1) AND ativo = '1'");
/*    */     try
/*    */     {
/* 21 */       ResultSet rs = banco.consulta(this.sql);
/* 22 */       if ((null != rs) && (rs.next())) {
/* 23 */         usuario.setIdUsuario(new Integer(rs.getInt("idUsuario")));
/* 24 */         usuario.setLogin(rs.getString("login"));
/* 25 */         usuario.setAtivo(rs.getString("ativo"));
/* 26 */         usuario.setNome(rs.getString("nome"));
                 usuario.setChefe(rs.getBoolean("chefe"));
                 usuario.setSetor(new Setor(rs.getInt("idSetor")));
/* 27 */         if (rs.getString("admin") == null) usuario.setAdmin("N"); else usuario.setAdmin("S"); 
/*    */       }
/*    */     }
/* 30 */     catch (Exception exception) { exception.printStackTrace(); }
/*    */ 
/*    */ 
/* 33 */     return usuario;
/*    */   }
/*    */ 
/*    */   public boolean alterarSenha(String login, String senhaAtual, String senhaNova)
/*    */   {
/* 38 */     Banco banco = Banco.getInstance();
/* 39 */     boolean flag = false;
/* 40 */     this.sql = ("SELECT * FROM usuario WHERE login = '" + login + "' AND (pwdcompare('" + senhaAtual + "', senha, 0) = 1) AND ativo = '1'");
/*    */     try
/*    */     {
/* 43 */       ResultSet rs = banco.consulta(this.sql);
/* 44 */       if (Banco.numLinhas(rs) != 0)
/*    */       {
/* 46 */         this.sql = ("UPDATE usuario SET senha=convert(varbinary(255), pwdencrypt('" + senhaNova + "')) WHERE login='" + login + "'");
/* 47 */         if (!banco.executa(this.sql))
/* 48 */           flag = true;
/*    */       }
/*    */     }
/*    */     catch (Exception exception) {
/* 52 */       exception.printStackTrace();
/*    */     }
/* 54 */     return flag;
/*    */   }
/*    */ 
/*    */   public boolean verificaConexao()
/*    */     throws Exception
/*    */   {
/* 63 */     Banco banco = Banco.getInstance();
/* 64 */     return banco.verificaConectividadeComBanco();
/*    */   }
/*    */ }

/* Location:           C:\Users\jonas\Documents\NetBeansProjects\sistrans\build\web\WEB-INF\classes\
 * Qualified Name:     bdSQL.LoginAction
 * JD-Core Version:    0.6.2
 */